The standard image-compression dialog component supplied by Apple allows you to extend the interface of the standard dialog box by defining a hook function. This section describes how that hook function operates.
This function is called by the standard dialog component whenever the user selects an item in the standard image-compression dialog box. You define the function in your application and assign it to a dialog box with the hookProc field of the scExtendedProcsType request, which is discussed on The Extended Functions Request Type .
This is how you would define a hook function called MyHook :
pascal short MyHook (DialogPtr theDialog, short itemHit,
void *params, long refcon);
Your hook function returns a short integer that identifies the item selected by the user. In general, your hook function should return the same item number it receives in the itemHit parameter. By returning a specific value, you can affect how the component handles the user selection. The following values are defined:
If you set the returned value to 0, you cancel the user selection; the dialog box remains on the screen awaiting further action by the user.
The hook function allows your application to tailor or extend the operation of the standard image-compression dialog box. By attaching your hook function to the dialog box, you intercept all user selections. For example, your hook function could perform additional parameter checking whenever the user clicks the OK button. In this case, whenever you detect an incorrect parameter value, you could display a message to the user and then set the returned value to 0, thereby canceling the user's selection. The user would then either cancel the dialog box or try again.
As another example, you could support additional parameters by implementing the dialog box's custom button. You could use your hook function to display a secondary dialog box whenever the user clicks the custom button. For an example of defining and using a custom button, see "Extending the Basic Dialog Box" beginning on Extending the Basic Dialog Box .